var t = getApp();

Page({
    data: {
        colora: "topbtn",
        colorb: "topbutton",
        parta: "",
        partb: "",
        partab: "",
        checkeditem: {},
        list1: [],
        list2: [],
        showlist: [],
        key: "",
        From: "",
        namelist: [],
        condition: "",
        netbol: !0,
        netok: !0
    },
    onLoad: function(a) {
        var e = this, o = a.id;
        if (this.setData({
            key: a.key,
            From: a.From,
            id: a.index,
            url: a.url,
            sessin: a.sessin,
            TopName: a.TopName,
            Listurl: a.Listurl
        }), "end" !== a.key) {
            this.setData({
                condition: !0,
                itemclass: "义务"
            });
            var i = "ObligrefID_" + o + "_list1", s = "ObligrefID_" + o + "_list2", l = "ObligrefID_" + o + "_parta", r = "ObligrefID_" + o + "_partb", n = t.globalData[i], d = t.globalData[s], c = t.globalData[l], b = t.globalData[r];
            n && d ? this.setData({
                list1: n,
                list2: d,
                showlist: n,
                parta: c + "义务",
                partb: b + "义务",
                partab: c + "义务",
                netok: !1
            }) : (wx.showToast({
                title: "数据加载中",
                icon: "loading",
                duration: 2e4
            }), wx.request({
                url: t.url + "addon/Oblig/Oblig/" + t.globalData.ObligrefUrl,
                data: {
                    id: o
                },
                method: "GET",
                header: {
                    "Content-Type": "application/json",
                    Cookie: "PHPSESSID=" + wx.getStorageSync("PHPSESSID")
                },
                success: function(a) {
                    wx.hideToast();
                    var o = a.data, n = [ o.a1, o.a2, o.a3, o.a4, o.a5, o.a6, o.a7, o.a8, o.a9, o.a10, o.a11, o.a12 ].filter(function(t) {
                        return void 0 !== t && null !== t && t.length > 0;
                    }), d = [ o.b1, o.b2, o.b3, o.b4, o.b5, o.b6, o.b7, o.b8, o.b9, o.b10, o.b11, o.b12 ].filter(function(t) {
                        return void 0 !== t && null !== t && t.length > 0;
                    });
                    e.setData({
                        list1: n,
                        list2: d,
                        showlist: n,
                        parta: o.parta + "义务",
                        partb: o.partb + "义务",
                        partab: o.parta + "义务",
                        netok: !1
                    }), wx.setStorageSync(i, n), wx.setStorageSync(s, d), wx.setStorageSync(l, o.parta), 
                    wx.setStorageSync(r, o.partb), t.globalData[i] = n, t.globalData[s] = d, t.globalData[l] = o.parta, 
                    t.globalData[r] = o.partb;
                },
                fail: function(t) {
                    wx.hideToast();
                    var a = wx.getStorageSync(i), o = wx.getStorageSync(s), n = wx.getStorageSync(l), d = wx.getStorageSync(r);
                    e.setData({
                        list1: a,
                        list2: o,
                        showlist: a,
                        parta: n + "义务",
                        partb: d + "义务",
                        partab: n + "义务"
                    }), a && o || (e.setData({
                        netbol: !1
                    }), wx.showToast({
                        title: "无法连接网络",
                        icon: "loading",
                        duration: 2600
                    }));
                }
            }));
        } else {
            this.setData({
                condition: !1,
                itemclass: ""
            });
            var g = t.globalData.EndSAVEdata;
            g ? (this.setData({
                Endlist: g
            }), console.log("结果2", g)) : wx.request({
                url: t.url + "addon/Modelend/Modelend/" + t.globalData.EndrefUrl,
                data: {},
                method: "GET",
                header: {
                    "Content-Type": "application/json",
                    Cookie: "PHPSESSID=" + wx.getStorageSync("PHPSESSID")
                },
                success: function(a) {
                    e.setData({
                        Endlist: a.data
                    }), t.globalData.EndSAVEdata = a.data, wx.setStorageSync("EndSAVEdata", a.data), 
                    console.log("结果1", a.data);
                },
                fail: function(t) {
                    var a = wx.getStorageSync("EndSAVEdata");
                    e.setData({
                        Endlist: a
                    }), a || (e.setData({
                        netbol: !1
                    }), wx.showToast({
                        title: "无法连接网络",
                        icon: "loading",
                        duration: 2e3
                    })), console.log("结果3", a);
                }
            });
        }
    },
    bindreturn: function(t) {
        var a = this.data.key, e = this.data.From, o = this.data.id, i = this.data.url, s = this.data.sessin;
        wx.redirectTo({
            url: "../SdraftOblig/SdraftOblig?key=" + a + "&From=" + e + "&id=" + o + "&url=" + i + "&sessin=" + s
        });
    },
    checkboxChange: function(t) {
        this.setData({
            checkeditem: t.detail.value
        });
    },
    addrefsubmit: function(a) {
        var e = this.data.key, o = this.data.From, i = this.data.checkeditem, s = this.data.id, l = this.data.url, r = this.data.sessin;
        if (1 == o) {
            n = wx.getStorageSync(e) || [];
            i.length > 0 && wx.setStorageSync(e, n.concat(i));
        }
        if (2 == o) {
            var n = t.globalData.htGet[e] || [];
            i.length > 0 && (t.globalData.htGet[e] = n.concat(i), t.globalData.alternot = 1);
        }
        wx.redirectTo({
            url: "../SdraftOblig/SdraftOblig?key=" + e + "&From=" + o + "&id=" + s + "&url=" + l + "&sessin=" + r
        });
    },
    AllSelect: function(a) {
        var e = this.data.key, o = this.data.From, i = (this.data.checkeditem, this.data.id), s = this.data.url, l = this.data.sessin;
        if (1 == o) {
            r = wx.getStorageSync(e) || [];
            wx.setStorageSync(e, r.concat(this.data.showlist));
        }
        if (2 == o) {
            var r = t.globalData.htGet[e] || [];
            t.globalData.htGet[e] = r.concat(this.data.showlist), t.globalData.alternot = 1;
        }
        wx.redirectTo({
            url: "../SdraftOblig/SdraftOblig?key=" + e + "&From=" + o + "&id=" + i + "&url=" + s + "&sessin=" + l
        });
    },
    selectnava: function() {
        this.setData({
            colora: "topbtn",
            colorb: "topbutton",
            showlist: this.data.list1,
            partab: this.data.parta
        });
    },
    selectnavb: function() {
        this.setData({
            colora: "topbutton",
            colorb: "topbtn",
            showlist: this.data.list2,
            partab: this.data.partb
        });
    }
});